package com.sky.config;

import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类用于创建AliossUtil的对象
 * @Author：chén jiā jùn
 * @Create：2023年11月15日18:59
 */

@Configuration
@Slf4j
public class OssConfiguration {
	@Bean
	@ConditionalOnMissingBean
	public AliOssUtil aliOssUtil(AliOssProperties alOssProperties) {
		log.info("开始创建阿里云文件上传的工具类对象：{}",alOssProperties);
		return new AliOssUtil(alOssProperties.getEndpoint(),
				alOssProperties.getAccessKeyId(),
				alOssProperties.getAccessKeySecret(),
				alOssProperties.getBucketName());
	}
}
